package com.demo.dao;


import javax.annotation.Resource;

import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.support.SqlSessionDaoSupport;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Repository;
/**
 * 
 * @author demo
 *
 */
@Scope("prototype")
@Repository
public class BaseDao extends SqlSessionDaoSupport  {
	
	@Resource
	private SqlSessionFactory sqlSessionFactory;
	
	
	
    public Integer insert(String statementName,Object parameterObject){

		return sqlSessionFactory.openSession().insert(statementName, parameterObject);
	}
	
	
	public Object queryForObject(String statementName,Object parameterObject){
		return sqlSessionFactory.openSession().selectOne(statementName,parameterObject);
	}
	

	public Object selectList(String statementName){
		return sqlSessionFactory.openSession().selectList(statementName);
	}
	
	public int updateObject(String statementName,Object parameterObject){
		return sqlSessionFactory.openSession().update(statementName, parameterObject);
	}
	
	public int deleteObject(String statementName,Object parameterObject){
		return sqlSessionFactory.openSession().delete(statementName, parameterObject);
	}


}
